package com.wyz.socket.core.base;

/**
 * 携带优先等级的 节点 可组成链
 *
 * @param <Item>
 */
public class ByteNode<Item> {
    public byte priority ;
    public Item item ;
    public ByteNode<Item> next ;

    public ByteNode(Item item) {
        this.item = item;
    }

    public void appendWithPriority(ByteNode<Item> node){
        if(next == null){
            next = node ;
        }else{
            ByteNode<Item> after = this.next;
            if(after.priority < node.priority){
                this.next = node;
                node.next = after;
            }else{
                after.appendWithPriority(node);
            }
        }
    }
}
